<extend name="Public/main" />

<block name="style">
	<script type="text/javascript">
		var catid = "12";
	</script>
	<style type="text/css">
		.col-auto {
			overflow: hidden;
			_zoom: 1;
			_float: left;
			border: 1px solid #c2d1d8;
		}
		.col-right {
			float: right;
			width: 210px;
			overflow: hidden;
			margin-left: 6px;
			border: 1px solid #c2d1d8;
		}

		body fieldset {
			border: 1px solid #D8D8D8;
			padding: 10px;
			background-color: #FFF;
		}
		body fieldset legend {
			background-color: #F9F9F9;
			border: 1px solid #D8D8D8;
			font-weight: 700;
			padding: 3px 8px;
		}
		.list-dot{ padding-bottom:10px}
		.list-dot li,.list-dot-othors li{padding:5px 0; border-bottom:1px dotted #c6dde0; font-family:"宋体"; color:#bbb; position:relative;_height:22px}
		.list-dot li span,.list-dot-othors li span{color:#004499}
		.list-dot li a.close span,.list-dot-othors li a.close span{display:none}
		.list-dot li a.close,.list-dot-othors li a.close{ background: url("__STATIC__/images/cross.png") no-repeat left 3px; display:block; width:16px; height:16px;position: absolute;outline:none;right:5px; bottom:5px}
		.list-dot li a.close:hover,.list-dot-othors li a.close:hover{background-position: left -46px}
		.list-dot-othors li{float:left;width:24%;overflow:hidden;}
	</style>
</block>

<block name="body">
	<div class="wrap J_check_wrap">
		<div class="nav">
			<ul class="cc">
				<li><a href="{:U('slide/index')}">所有幻灯片</a></li>
				<li class="current" ><a href="{:U('slide/add')}" >添加幻灯片</a></li>
			</ul>
		</div>
		<form name="myform" id="myform" action="#" method="post" class="J_ajaxForms" enctype="multipart/form-data">
			<div class="col-right">
				<div class="table_full">
					<table width="100%">
						<tr>
							<td><b>缩略图</b></td>
						</tr>
						<tr>
							<td>
								<div  style="text-align: center;"><input type='hidden' name='slide_pic' id='thumb' value=''>
									<a href='javascript:void(0);' onclick="flashupload('thumb_images', '附件上传', 'thumb', thumb_images, '1,jpg|jpeg|gif|png|bmp,1,,,1', 'content', '12', 'b6ba209759e147124653ac77362ef2bd');
											return false;">
										<img src='__STATIC__/images/icon/upload-pic.png' id='thumb_preview' width='135' height='113' style='cursor:hand' /></a>
									<input type="button"  class="btn" onclick="$('#thumb_preview').attr('src', '__STATIC__/images/icon/upload-pic.png');
											$('#thumb').val('');
											return false;" value="取消图片">
									<script type="text/javascript">
										function crop_cut_thumb(id) {
											if (id == '' || id == undefined) {
												isalert('请先上传缩略图！');
												return false;
											}
											var catid = $('input[name="info[catid]"]').val();
											if (catid == '') {
												isalert('请选择栏目ID！');
												return false;
											}
											Wind.use('artDialog', 'iframeTools', function() {
												art.dialog.open(GV.DIMAUB + 'index.php?a=public_imagescrop&m=Content&g=Contents&catid=' + catid + '&picurl=' + encodeURIComponent(id) + '&input=thumb&preview=thumb_preview', {
													title: '裁减图片',
													id: 'crop',
													ok: function() {
														var iframe = this.iframe.contentWindow;
														if (!iframe.document.body) {
															alert('iframe还没加载完毕呢');
															return false;
														}
														iframe.uploadfile();
														return false;
													},
													cancel: true
												});
											});
										}
										;
									</script></div>
							</td>
						</tr>

					</table>
				</div>
			</div>
			<div class="col-auto">
				<div class="h_a">幻灯片内容</div>
				<div class="table_full">
					<table width="100%">
						<tr>
							<th width="80">栏目</th>
							<td>
								<select name="slide_cid">
									<option value="0">默认分类</option>
									<foreach name="categorys" item="vo">
										<option value="{$vo.cid}">{$vo.cat_name}</option>
									</foreach>
								</select>
							</td>
						</tr>
						<tr>
							<th width="80">幻灯片名称</th>
							<td>
								<input type="text" style="width:400px;" name="slide_name" id="title" value="" style="color:" class="input input_hd J_title_color" placeholder="请输入幻灯片名称" onkeyup="strlen_verify(this, 'title_len', 160)" />
								<span class="must_red">*</span>
							</td>
						</tr>
						<tr>
							<th width="80">链接地址：</th>
							<td>
								<input type='text' name='slide_url'  value='' style='width:400px' class='input  input_hd J_title_color'>
							</td>
						</tr>
						<tr>
							<th width="80">描述</th>
							<td><input type='text' name='slide_des'  value='' style='width:400px' class='input  input_hd J_title_color'></td>
						</tr>
						<tr>
							<th width="80">幻灯片内容</th>
							<td>

								<textarea name='slide_content' id='description' style='width:98%;height:200px;'  ></textarea>
							</td>
						</tr>


						</tbody>
					</table>
				</div>
			</div>
			<div class="btn_wrap" style="z-index:999;text-align: center;">
				<div class="btn_wrap_pd">
					<input value="56" type="hidden" name="id">
					<input type="hidden" name="catid" value="12" />
					<input type="hidden" name="ajax" value="1" />
					<button class="btn btn_submit J_ajax_submit_btn"type="submit">提交</button>
					<!-- <button class="btn J_ajax_close_btn"type="submit">关闭</button> -->
				</div>
			</div>
		</form>
	</div>
</block>
<block name="script">
	<script type="text/javascript" src="__STATIC__/js/content_addtop.js{$js_debug}"></script>
	<script type="text/javascript">
									$(function() {
										//setInterval(function(){public_lock_renewal();}, 10000);
										$(".J_ajax_close_btn").on('click', function(e) {
											e.preventDefault();
											Wind.use("artDialog", function() {
												art.dialog({
													id: "question",
													icon: "question",
													fixed: true,
													lock: true,
													background: "#CCCCCC",
													opacity: 0,
													content: "您确定需要关闭当前页面嘛？",
													ok: function() {
														setCookie("refersh_time", 1);
														window.close();
														return true;
													}
												});
											});
										});
										/////---------------------
										Wind.use('validate', 'ajaxForm', 'artDialog', function() {
											//javascript

											var form = $('form.J_ajaxForms');
											//ie处理placeholder提交问题
											if ($.browser.msie) {
												form.find('[placeholder]').each(function() {
													var input = $(this);
													if (input.val() == input.attr('placeholder')) {
														input.val('');
													}
												});
											}
											//表单验证开始
											form.validate({
												//是否在获取焦点时验证
												onfocusout: false,
												//是否在敲击键盘时验证
												onkeyup: false,
												//当鼠标掉级时验证
												onclick: false,
												//验证错误
												showErrors: function(errorMap, errorArr) {
													//errorMap {'name':'错误信息'}
													//errorArr [{'message':'错误信息',element:({})}]
													try {
														$(errorArr[0].element).focus();
														art.dialog({
															id: 'error',
															icon: 'error',
															lock: true,
															fixed: true,
															background: "#CCCCCC",
															opacity: 0,
															content: errorArr[0].message,
															cancelVal: '确定',
															cancel: function() {
																$(errorArr[0].element).focus();
															}
														});
													} catch (err) {
													}
												},
												//验证规则
												rules: {'slide_name': {required: 1}},
												//验证未通过提示消息
												messages: {'slide_name': {required: '请输入名称'}},
												//给未通过验证的元素加效果,闪烁等
												highlight: false,
												//是否在获取焦点时验证
												onfocusout: false,
														//验证通过，提交表单
														submitHandler: function(forms) {
															$(forms).ajaxSubmit({
																url: form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
																dataType: 'json',
																beforeSubmit: function(arr, $form, options) {

																},
																success: function(data, statusText, xhr, $form) {
																	if (data.status) {
																		setCookie("refersh_time", 1);
																		//添加成功
																		Wind.use("artDialog", function() {
																			art.dialog({
																				id: "succeed",
																				icon: "succeed",
																				fixed: true,
																				lock: true,
																				background: "#CCCCCC",
																				opacity: 0,
																				content: data.info,
																				button: [
																					{
																						name: '继续添加？',
																						callback: function() {
																							reloadPage(window);
																							return true;
																						},
																						focus: true
																					}, {
																						name: '关闭',
																						callback: function() {
																							//window.close();
																							return true;
																						}
																					}
																				]
																			});
																		});
																	} else {
																		isalert(data.info);
																	}
																}
															});
														}
											});
										});
										////-------------------------
									});
	</script>
</block>